package com.foreveross.proxyip.application.offer.rest.provider;


import java.io.Serializable;
import java.util.Collections;

/**
 * 
 * @author loudyn
 * 
 */
public class RestResponse implements Serializable {

	private static final long serialVersionUID = 1L;

	private final int status;
	private final String message;
	private final Object result;

	RestResponse(Builder builder) {
		this.status = builder.status;
		this.message = builder.message;
		this.result = builder.result;
	}

	public int getStatus() {
		return status;
	}

	public String getMessage() {
		return message;
	}

	public Object getResult() {
		return result;
	}

	/**
	 * 
	 * @author loudyn
	 * 
	 */
	public static class Builder {
		private int status = 1;
		private String message;
		private Object result;

		public Builder ok() {
			this.status = 1;
			return this;
		}

		public Builder error() {
			this.status = -1;
			this.result = Collections.emptyMap();
			return this;
		}

		public Builder message(String message) {
			this.message = message;
			return this;
		}

		public Builder result(Object result) {
			this.result = result;
			return this;
		}

		public RestResponse build() {
			return new RestResponse(this);
		}
	}

}
